//
//  FlyHomeTableViewCell.m
//  JiongTu
//
//  Created by Dupengfei on 16/3/25.
//  Copyright © 2016年 YSKJ. All rights reserved.
//

#import "FlyHomeTableViewCell.h"

#import "UIView+Extension.h"
#import "JTPassengerTrip.h"
#import "JTDriverTrip.h"
#import "JTUser.h"

#import "UIImageView+WebCache.h"

@interface FlyHomeTableViewCell ()

/**
 *  头像
 */
@property (weak, nonatomic) IBOutlet UIImageView *headImage;
/**
 *  昵称
 */
@property (weak, nonatomic) IBOutlet UILabel *nickName;
/**
 *  身份
 */
@property (weak, nonatomic) IBOutlet UILabel *identity;
/**
 *  出发
 */
@property (weak, nonatomic) IBOutlet UILabel *startLocation;

/**
 *  目的地
 */
@property (weak, nonatomic) IBOutlet UILabel *endLocation;
/**
 *  时间
 */
@property (weak, nonatomic) IBOutlet UILabel *time;

@end

@implementation FlyHomeTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.headImage.layer.cornerRadius = self.headImage.height * 0.5;
    self.headImage.layer.masksToBounds = YES;
}

- (void)setTripObject:(id)tripObject {
    _tripObject = tripObject;
    
    if ([tripObject isKindOfClass:[JTPassengerTrip class]]) {
        JTPassengerTrip *passengerTrip = tripObject;
        self.identity.text = passengerTrip.identity;
        self.endLocation.text = passengerTrip.end;
        self.startLocation.text = passengerTrip.start;
        self.time.text = passengerTrip.time;
        self.nickName.text = passengerTrip.passenger.nickname;
        [self.headImage sd_setImageWithURL:passengerTrip.passenger.iconPath placeholderImage:[UIImage imageNamed:@"头像占位"]];
    } else if ([tripObject isKindOfClass:[JTDriverTrip class]]) {
        JTDriverTrip *driverTrip = tripObject;
        self.identity.text = driverTrip.identity;
        self.endLocation.text = driverTrip.end;
        self.startLocation.text = driverTrip.start;
        self.time.text = driverTrip.time;
        self.nickName.text = driverTrip.driver.nickname;
        [self.headImage sd_setImageWithURL:driverTrip.driver.iconPath placeholderImage:[UIImage imageNamed:@"头像占位"]];
    }
}

@end
